<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Models\FlowPv;
use App\Models\FlowUv;

class CenterController extends Controller{
	
	public function __construct(){
		$count['pvone'] = FlowPv::where('create_time', '>', date('Y-m-d', time()) . ' 00:00:00')->count();
		$count['pvall'] = FlowPv::count();
		$count['uvone'] = FlowUv::where('create_time', '>', date('Y-m-d', time()) . ' 00:00:00')->count();
		$count['uvall'] = FlowUv::count();
		view()->share("count", $count);
	}
	
	public function getCenter(){
		return view("Admin.Center.center");
	}
	
	public function getPv(){
		$data = FlowPv::orderBy('pv_id', 'desc')->paginate(15);
		view()->share("data", $data);
		view()->share("key", 'pv');
		return view("Admin.Center.index");
	}
	
	public function getUv(){
		$data = FlowUv::orderBy('uv_id', 'desc')->paginate(15);
		view()->share("data", $data);
		view()->share("key", 'uv');
		return view("Admin.Center.index");
	}
	
}